<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSGO地图胜率 - 示例玩家</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap">
    <style>
        /* 注意: 为了在任何环境下都能显示，这里移除了本地字体文件引用。
           如果你有特定的自定义字体文件 (.ttf)，你需要将它们上传到你的服务器，
           并在这里更新正确的 URL 路径，例如:
           @font-face {
               font-family: AlibabaHealthFont2;
               src: url("https://your-domain.com/fonts/AlibabaHealthFont2.0CN-85B.ttf");
           }
           @font-face {
               font-family: fzrzFont;
               src: url("https://your-domain.com/fonts/fzrzFont.ttf");
           }
        */

        :root {
            --primary-bg: #fff5f7;
            --card-bg: white;
            --border-color-light: #f3868c;
            --shadow-color-light: rgba(247, 123, 142, 0.15);
            --gradient-start: #f67186;
            --gradient-end: #f7889c;
            --text-dark: #333333;
            --text-highlight: #f67186;
            --section-title-bar: #f67186;
            --section-title-bar-end: #f7889c;
            --csgo-t-side-color: #ffc107;
            --csgo-ct-side-color: #2196f3;
            --csgo-win-color: #4CAF50;
            --csgo-lose-color: #F44336;
        }

        body {
            margin: 0;
            padding: 0;
            background-color: var(--primary-bg);
            background-image: linear-gradient(45deg, rgba(247, 123, 142, 0.05) 25%, transparent 25%, transparent 75%, rgba(247, 123, 142, 0.05) 75%, rgba(247, 123, 142, 0.05)),
                linear-gradient(45deg, rgba(247, 123, 142, 0.05) 25%, transparent 25%, transparent 75%, rgba(247, 123, 142, 0.05) 75%, rgba(247, 123, 142, 0.05));
            background-size: 60px 60px;
            background-position: 0 0, 30px 30px;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            min-height: 100vh;
            /* 优先使用 Inter 字体，如果定义了自定义字体，可以放在前面 */
            font-family: "Inter", sans-serif; 
        }

        .wrapper {
            width: 900px;
            background: var(--card-bg);
            border-radius: 20px;
            padding: 35px 30px;
            box-sizing: border-box;
            box-shadow: 0 15px 40px var(--shadow-color-light);
            margin: 40px 0;
            display: flex;
            flex-direction: column;
            gap: 30px;
            position: relative;
            overflow: hidden;
        }

        .wrapper::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 6px;
            background: linear-gradient(to right, var(--gradient-start), var(--gradient-end));
        }

        .app-header {
            text-align: center;
            position: relative;
            padding-bottom: 25px;
        }

        .app-title {
            font-size: 38px;
            background: linear-gradient(to right, var(--gradient-start), var(--gradient-end));
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            margin: 10px 0;
            font-weight: 800;
            letter-spacing: -0.5px;
            text-shadow: 0 2px 10px rgba(247, 123, 142, 0.2);
        }

        .app-subtitle {
            font-size: 16px;
            color: var(--gradient-end);
            margin: 0;
            font-weight: 500;
            letter-spacing: 1px;
        }

        .info-box {
            position: relative;
            background: var(--card-bg);
            border: 2px solid var(--border-color-light);
            border-radius: 16px;
            padding: 25px;
            box-shadow: 0 8px 16px var(--shadow-color-light);
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .section-title {
            /* 如果 fzrzFont 未加载，会回退到 Inter */
            font-family: "fzrzFont", "Inter", sans-serif; 
            font-size: 24px;
            color: var(--text-highlight);
            margin: 0 0 20px 0;
            display: flex;
            align-items: center;
            font-weight: bold;
        }

        .section-title:before {
            content: "";
            display: inline-block;
            width: 8px;
            height: 24px;
            background: linear-gradient(to bottom, var(--section-title-bar), var(--section-title-bar-end));
            margin-right: 12px;
            border-radius: 4px;
        }

        .player-info-panel {
            display: flex;
            align-items: center;
            padding-bottom: 25px;
            border-bottom: 1px dashed rgba(247, 123, 142, 0.3);
            margin-bottom: 25px;
        }

        .player-avatar {
            width: 110px;
            height: 110px;
            border-radius: 50%;
            object-fit: cover;
            border: 4px solid var(--gradient-start);
            margin-right: 25px;
            box-shadow: 0 5px 15px rgba(247, 123, 142, 0.3);
        }

        .player-details {
            flex-grow: 1;
        }

        .player-name {
            font-size: 28px;
            font-weight: 800;
            margin: 0 0 8px 0;
            background: linear-gradient(to right, var(--gradient-start), var(--gradient-end));
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            letter-spacing: -0.5px;
        }

        .steam-id {
            font-size: 15px;
            color: #888;
            margin: 0;
            display: flex;
            align-items: center;
        }

        .steam-id::before {
            content: "";
            display: inline-block;
            width: 16px;
            height: 16px;
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="%23888" d="M496 256c0 137-111.2 248-248.4 248-113.8 0-209.6-76.3-239-180.4l95.2 39.3c6.4 32.1 34.9 56.4 68.9 56.4 39.2 0 71.9-32.4 70.2-73.5l84.5-60.2c52.1 1.3 95.8-40.9 95.8-93.5 0-51.6-42-93.5-93.7-93.5s-93.7 42-93.7 93.5v1.2L176.6 279c-15.5-.9-30.7 3.4-43.5 12.1L0 236.1C10.2 108.4 117.1 8 247.6 8 384.8 8 496 119 496 256zM155.7 384.3l-30.5-12.6a52.79 52.79 0 0 0 27.2 25.8c26.9 11.2 57.8-1.6 69-28.4 5.4-13 5.5-27.3.1-40.3-5.4-13-15.5-23.2-28.5-28.6-12.9-5.4-26.7-5.2-38.9-.6l31.5 13c19.8 8.2 29.2 30.9 20.9 50.7-8.3 19.9-31 29.2-50.8 21zm173.8-129.9c-34.4 0-62.4-28-62.4-62.3s28-62.3 62.4-62.3 62.4 28 62.4 62.3-27.9 62.3-62.4 62.3zm.1-15.6c25.9 0 46.9-21 46.9-46.8 0-25.9-21-46.8-46.9-46.8s-46.9 21-46.9 46.8c.1 25.8 21.1 46.8 46.9 46.8z"/></svg>');
            background-repeat: no-repeat;
            background-position: center;
            margin-right: 6px;
        }

        .meta-container {
            position: relative;
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 30px;
            background: var(--card-bg);
            border: 2px solid var(--border-color-light);
            border-radius: 12px;
            padding: 15px;
            box-shadow: 0 4px 8px var(--shadow-color-light);
            margin-bottom: 25px;
        }

        .meta-item {
            text-align: center;
            flex-basis: auto;
            min-width: 120px;
        }

        .meta-label {
            font-size: 14px;
            color: var(--text-highlight);
            margin-bottom: 5px;
        }

        .meta-value {
            font-size: 16px;
            color: var(--text-dark);
            font-weight: bold;
        }

        .divider {
            height: 1px;
            background: linear-gradient(to right, transparent, var(--gradient-end), transparent);
            margin: 0;
        }

        /* 地图列表网格 */
        .maps-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr); /* 始终两列 */
            gap: 25px;
            margin-top: 25px;
        }

        .map-card {
            background: rgba(255, 250, 250, 0.9);
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 5px 15px rgba(247, 123, 142, 0.12);
            display: flex;
            flex-direction: column;
            transition: all 0.3s ease;
            position: relative;
            height: 100%;
        }

        .map-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(247, 123, 142, 0.25);
        }

        .map-header {
            position: relative;
            height: 120px;
            overflow: hidden;
            background: linear-gradient(135deg, rgba(247, 123, 142, 0.1), rgba(247, 123, 142, 0.05));
        }

        .map-logo {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s ease;
        }

        .map-card:hover .map-logo {
            transform: scale(1.05);
        }

        .map-content {
            padding: 20px;
            display: flex; /* Make content a flex container */
            flex-direction: column; /* Stack items vertically */
            gap: 15px; /* Spacing between sections in map-content */
        }

        .map-name-display {
            font-size: 18px;
            font-weight: bold;
            color: var(--text-dark);
            text-align: center;
        }

        /* New styles for general stats summary */
        .map-stats-summary {
            display: flex;
            justify-content: space-around;
            align-items: center;
            background: rgba(247, 123, 142, 0.08);
            border-radius: 10px;
            padding: 10px;
            flex-wrap: wrap; /* Allow wrapping for smaller screens */
            gap: 10px; /* Gap between summary items */
        }

        .summary-item {
            text-align: center;
            flex: 1; /* Distribute space evenly */
            min-width: 80px; /* Minimum width for summary items */
        }

        .summary-label {
            font-size: 12px;
            color: var(--text-highlight);
            margin-bottom: 3px;
        }

        .summary-value {
            font-size: 16px;
            font-weight: bold;
            color: var(--text-dark);
        }

        .map-winrate-row {
            width: 100%;
            text-align: center;
            background: linear-gradient(to right, var(--gradient-start), var(--gradient-end));
            color: white;
            padding: 12px 0;
            border-radius: 10px;
            font-size: 20px;
            font-weight: bold;
            box-shadow: 0 4px 10px rgba(247, 123, 142, 0.2);
        }

        .win-rate-progress {
            height: 8px;
            background-color: rgba(247, 123, 142, 0.2);
            border-radius: 4px;
            margin: 0; /* Remove top/bottom margin here as gap handles it */
            overflow: hidden;
            width: 100%;
        }

        .progress-fill {
            height: 100%;
            background: linear-gradient(90deg, var(--csgo-win-color), #8BC34A);
            border-radius: 4px;
            transition: width 1s ease-in-out;
        }

        .side-win-rates {
            display: flex;
            justify-content: space-around;
            width: 100%;
            padding-top: 15px;
            border-top: 1px dashed rgba(247, 123, 142, 0.2);
        }

        .side-rate-item {
            text-align: center;
            padding: 8px 15px;
            border-radius: 8px;
            flex: 1; /* Distribute space */
            margin: 0 5px; /* Small horizontal margin */
        }

        .side-rate-label {
            font-size: 13px;
            color: #666;
            margin-bottom: 5px;
        }

        .side-rate-value {
            font-size: 16px;
            font-weight: bold;
        }

        .t-side-color {
            color: var(--csgo-t-side-color);
            background-color: rgba(255, 193, 7, 0.1); /* Add light background */
        }

        .ct-side-color {
            color: var(--csgo-ct-side-color);
            background-color: rgba(33, 150, 243, 0.1); /* Add light background */
        }

        /* New styles for detailed stats grid */
        .map-detailed-stats-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr); /* Three columns for detailed stats */
            gap: 10px; /* Smaller gap for more items */
            padding-top: 15px;
            border-top: 1px dashed rgba(247, 123, 142, 0.2);
        }

        .detail-item {
            background: rgba(247, 123, 142, 0.05); /* Lighter background for detail items */
            border-radius: 8px;
            padding: 8px;
            text-align: center;
        }

        .detail-label {
            font-size: 11px;
            color: #888;
            margin-bottom: 2px;
        }

        .detail-value {
            font-size: 15px;
            font-weight: bold;
            color: var(--text-dark);
        }

        .footer {
            text-align: center;
            padding: 20px 0 10px;
            font-size: 13px;
            color: #888;
            border-top: 1px solid rgba(247, 123, 142, 0.1);
            margin-top: 10px;
            position: relative;
        }

        .footer::after {
            content: "";
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 100px;
            height: 3px;
            background: linear-gradient(to right, var(--gradient-start), var(--gradient-end));
            border-radius: 3px;
        }
    </style>
</head>

<body>
    <div class="wrapper">
        <div class="app-header">
            <h1 class="app-title">完美CSGO地图数据</h1>
            <p class="app-subtitle">CSGO MAP WINRATE OVERVIEW</p>
        </div>

        <div class="info-box">
            <h3 class="section-title">玩家概览</h3>
            <div class="player-info-panel">
                <img src="{{avatar_url}}" alt="用户头像" class="player-avatar">
                <div class="player-details">
                    <h2 class="player-name">{{player_name}}</h2>
                    <p class="steam-id">{{steam_id}}</p>
                </div>
            </div>

            <div class="meta-container">
                <div class="meta-item">
                    <div class="meta-label">当前赛季</div>
                    <div class="meta-value">{{season}}</div>
                </div>
            </div>
        </div>

        <div class="divider"></div>

        <div class="info-box">
            <h3 class="section-title">常用地图胜率</h3>
            <div class="maps-grid">
  
                {% for map in maps %}
                <div class="map-card">
                    <div class="map-header">
                        <img src="{{ map.map_image }}" alt="{{ map.map_name }}" class="map-logo">
                    </div>
                    <div class="map-content">
                        <div class="map-name-display">{{ map.map_name }} [{{ map.map }}]</div>

                        <div class="map-stats-summary">
                            <div class="summary-item">
                                <div class="summary-label">比赛场次</div>
                                <div class="summary-value">{{ map.total_match }}</div>
                            </div>
                            <div class="summary-item">
                                <div class="summary-label">胜利场次</div>
                                <div class="summary-value">{{ map.win_count }}</div>
                            </div>
                            {% if map.rank is not none %}
                            <div class="summary-item">
                                <div class="summary-label">地图排名</div>
                                <div class="summary-value">{{ map.rank }}</div>
                            </div>
                            {% endif %}
                        </div>

                        {# 胜率独占一行显示 #}
                        <div class="map-winrate-row">
                            胜率: {{ "%.1f"|format((map.win_count / map.total_match * 100) if map.total_match > 0 else 0) }}%
                        </div>

                        <div class="win-rate-progress">
                            <div class="progress-fill" style="width: {{ (map.win_count / map.total_match * 100) if map.total_match > 0 else 0 }}%;"></div>
                        </div>

                        <div class="side-win-rates">
                            {# HotMap 模型中未直接提供 T方/CT方胜率，这里显示 N/A #}
                            <div class="side-rate-item t-side-color">
                                <div class="side-rate-label">T方胜率</div>
                                <div class="side-rate-value">
				{% if map['map_rate'] %}{{(map['map_rate']['t_win_rate']* 100)| round(0)}}%{% else %}N/A{% endif %}
				</div>
                            </div>
                            <div class="side-rate-item ct-side-color">
                                <div class="side-rate-label">CT方胜率</div>
                                <div class="side-rate-value">
					{% if map['map_rate'] %}{{(map['map_rate']['ct_win_rate']* 100)| round(0)}}%{% else %}N/A{% endif %}
				</div>
                            </div>
                        </div>

                        <div class="map-detailed-stats-grid">
                            <div class="detail-item">
                                <div class="detail-label">RATING PRO</div>
                                <div class="detail-value">{{ "%.2f"|format((map.rating_sum / map.total_match) if map.total_match > 0 else 0) }}</div>
                            </div>
                            <div class="detail-item">
                                <div class="detail-label">K/D</div>
                                <div class="detail-value">{{ "%.2f"|format((map.total_kill / map.death_num) if map.death_num > 0 else 0) }}</div>
                            </div>
                            <div class="detail-item">
                                <div class="detail-label">ADR</div>
                                <div class="detail-value">{{ "%.2f"|format((map.total_adr / map.total_match) if map.total_match > 0 else 0) }}</div>
                            </div>
                            <div class="detail-item">
                                <div class="detail-label">爆头率</div>
                                <div class="detail-value">{{ "%.1f"|format((map.headshot_kill_num / map.total_kill * 100) if map.total_kill > 0 else 0) }}%</div>
                            </div>
                            <div class="detail-item">
                                <div class="detail-label">MVP数</div>
                                <div class="detail-value">{{ map.match_mvp_num }}</div>
                            </div>
                            <div class="detail-item">
                                <div class="detail-label">三杀</div>
                                <div class="detail-value">{{ map.three_kill_num }}</div>
                            </div>
                            <div class="detail-item">
                                <div class="detail-label">四杀</div>
                                <div class="detail-value">{{ map.four_kill_num }}</div>
                            </div>
                            <div class="detail-item">
                                <div class="detail-label">五杀</div>
                                <div class="detail-value">{{ map.five_kill_num }}</div>
                            </div>
                            <div class="detail-item">
                                <div class="detail-label">1v3胜</div>
                                <div class="detail-value">{{ map.v3_num }}</div>
                            </div>
                            <div class="detail-item">
                                <div class="detail-label">1v4胜</div>
                                <div class="detail-value">{{ map.v4_num }}</div>
                            </div>
                            <div class="detail-item">
                                <div class="detail-label">1v5胜</div>
                                <div class="detail-value">{{ map.v5_num }}</div>
                            </div>
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>
        </div>

        <div class="footer">
            完美CSGO地图数据查询 | Zhenxun Bot
        </div>
    </div>
</body>

</html>